//
//  MainViewController.swift
//  sina
//
//  Created by DXapple on 15/11/9.
//  Copyright © 2015年 sqlite. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
 
    @objc private func composeDidClick() {
    
//    print(__FUNCTION__)
        let compose = ComposeViewController()
        let nav = UINavigationController(rootViewController: compose)
        presentViewController(nav, animated: true, completion: nil)
        
    
    }
    
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let mainTabBar = MainTabBar()
        
        setValue(mainTabBar, forKey: "tabBar")
        
        addChildViewControllers()

            mainTabBar.composeBtn.addTarget(self, action: "composeDidClick", forControlEvents: UIControlEvents.TouchUpInside)
    
    }

    
    private func addChildViewControllers() {
    
        addChildViewController(HomeTableViewController(), title: "首页", imageName:"tabbar_home")
        addChildViewController(MessageTableViewController(), title: "消息", imageName:"tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName:"tabbar_discover")
        addChildViewController(ProfileTableViewController(), title: "我", imageName:"tabbar_profile")
        
        

        
        
    }

    private func addChildViewController(con: UIViewController, title: String, imageName: String) {
        
//        tabBar.tintColor = UIColor.orangeColor()
        
        let nav = BaseNavViewController(rootViewController: con)
        
        con.title = title
        
        con.tabBarItem.image = UIImage(named: imageName)
        
        addChildViewController(nav)
    
        
    
    }
        
    
    
    
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    


}
